package com.demo.controller;

import com.demo.model.Student;
import com.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * @author krystal
 * @date 2023/3/6 18:37
 */
@Controller
public class StudentController {
//    //1、使用属性注入获取bean
//    @Autowired
//    private StudentService studentService;

//    //2、set注入
//    private StudentService studentService;
//
//    @Autowired
//    public void setStudentService(StudentService studentService){
//        this.studentService=studentService;
//    }

//    //3、构造方法注入
//    private final StudentService studentService;
//
//    public StudentController(StudentService studentService){
//        this.studentService=studentService;
//    }

//    @Resource
//    private StudentService studentService;
//
//    public void sayHi(){
//        //调用service方法
//        studentService.sayHi();
//    }

    //@Resource(name = "baekhyun")
    //@Autowired
    @Qualifier("do")
    private Student student;

    public void sayHi(){
        System.out.println(student.toString());
    }
}
